package com.example.howard.xiao7music.model;

import com.example.howard.xiao7music.bean.PlayBean;
import com.example.howard.xiao7music.bean.SingerSongBean;
import com.example.howard.xiao7music.bean.SongDownloadBean;
import com.example.howard.xiao7music.bean.SongRankingBean;
import com.example.howard.xiao7music.model.getbasedata.Injection;

import retrofit2.Call;

/**
 * Created by Howard on 2016/9/24.
 */
public class GetRemoteSourceClass implements GetResource.GetRemoteSource {
    @Override
    public Call<SongRankingBean> getSongRanking(int num) {
        Call<SongRankingBean> call = Injection.provideSongAPI()
                .getSongRanking("json", "", "webapp_music", "baidu.ting.billboard.billList", num, 50, 0);
        return call;
    }

    @Override
    public Call<SingerSongBean> getSingerSong(String singerid) {
        Call<SingerSongBean> call = Injection.provideSongAPI()
                .getSingerSong("json", "", "webapp_music", "baidu.ting.artist.getSongList", singerid, 20, 1, 2);
        return call;
    }
    //原始方法根据百度歌曲API获得返回JSON，用的是GET方法，部分地方成get不能用UTF-8,只能用iso-8859-1，经测试，MIUI8不需要转编码
    @Override
    public String getSearch(String query) {
        String path = "http://tingapi.ting.baidu.com/v1/restserver/ting?format=json&calback=&from=webapp_music&method=baidu.ting.search.catalogSug&query="
                +query ;
//        String path=new String(path1.getBytes("UTF-8"),"iso-8859-1");
        return path;
    }

    @Override
    public Call<PlayBean> getPlay(String songid) {
        Call<PlayBean> call = Injection.provideSongAPI()
                .getPlay("json", "", "webapp_music", "baidu.ting.song.playAAC",songid);
        return call;
    }

    @Override
    public Call<SongDownloadBean> getdownloadsong(long songid) {
        Call<SongDownloadBean> call = Injection.provideSongAPI()
                .getdownloadsong("json", "","webapp_music" ,"baidu.ting.song.downWeb",songid,64,1393123213);
        return call;
    }
}
